<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body{padding: 20px;margin: 0;}
    .l,.r{
      width: 100px;
      height: 100px;
      background: pink;
      margin: 10px;
    }
    .r{ background: blue;}
  </style>

</head>
<body>
  <a href="https://segmentfault.com/a/1190000013647777">前端面试题-BFC(块格式化上下文)</a>
  <h3>BFC全称是Block Formatting Context，意思就是块级格式化上下文。你可以把BFC看做一个容器，容器里边的元素不会影响到容器外部的元素。</h3>
  <h3>同一个BFC内子元素margin会相互折叠</h3>
  <h3>非BFC，两个相邻的块级盒子的垂直外边距会发生重叠</h3>
  <div class="l"></div>
  <div class="r"></div>
  <!-- 浮动生成BFC -->
  <style>
    .f_l,.f_r{
      display: float;
      float: left;
    }
  </style>
  <h3>浮动生成BFC</h3>
  <div style="overflow: hidden;">
    <div class="f_l l"></div>
    <div class="f_r r"></div>
  </div>

  <style>
    .p_l,.p_r{
      position: absolute;
      left: 0;
    }
    .p_r{
      left: 100px;
    }
  </style>
  <!-- 定位absolute fixed生成BFC -->
  <h3>定位生成BFC</h3>
  <div>
    <div class="p_l l"></div>
    <div class="p_r r"></div>
  </div>

</body>
</html>